package LeetCode;

import java.util.ArrayList;
import java.util.List;

/**
 * @Classname LC897
 * @Description // https://leetcode-cn.com/problems/increasing-order-search-tree/ 树
 * @Date 2021/4/21 20:49
 * @Created by yin
 */
public class LC897 {
    private final ArrayList<Integer> vals = new ArrayList<>();

    public TreeNode increasingBST(TreeNode root) {
        inorder(root);
        TreeNode ans = new TreeNode(0), cur = ans;
        for (int v : vals) {
            cur.right = new TreeNode(v);
            cur = cur.right;
        }
        return ans.right;
    }

    public void inorder(TreeNode node) {
        if (node == null) return;
        inorder(node.left);
        vals.add(node.val);
        inorder(node.right);
    }

}
